package thinkinginjava;

public class CloneDemo implements Cloneable{
	private String name;
	
	public CloneDemo(String name) {
		this.name = name;
	}

	public Object clone() {
		CloneDemo cd = new CloneDemo(this.getName());
		System.out.println("cloned");
		return cd;
	}

	public void print(CloneDemo c) {
		System.out.println(c.getName());
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	public static void main(String[] args) {
		CloneDemo c = new CloneDemo("test");
		c.print(c);
	}
}
